package cn.wicking.mapper;

import cn.wicking.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.HashMap;
import java.util.List;

public interface UserMapper {


    @Insert("insert into user(id,name,pwd) values (#{id},#{username},#{password})")
    Integer insertUser(User user);
    @Update("update user set name=#{username},pwd=#{password} where id = #{id}")
    Integer updateUser(User user);
    @Delete("delete from user where id = #{id}")
    Integer deleteUser(@Param("id") Integer id);

    /**
     * 下面无法查询，因为实体类参数与数据库字段名不一致
     */
    @Select("select * from user where id = #{id}")
    User getUserById(@Param("id") Integer id);

    @Select("select * from user where name like concat('%',#{key},'%')")
    List<User> getUserMessageAmbiguous(@Param("key") String key);

    @Select("select * from user limit #{startPage},#{pageSize}")
    List<User> getUserMessageByPage(HashMap<String, Object> map);

    @Select("select * from user")
    List<User> gteUserByRowBounds();
}
